package com.example.lenovo.appstore.activity;

import android.graphics.Color;
import android.os.Bundle;

import com.example.lenovo.appstore.adapter.RankListAdapter;
import com.example.lenovo.appstore.utils.AppContext;
import com.example.lenovo.appstore.utils.StatusBarUtil;
import com.example.lenovo.appstore.view.TitleBarView;
import com.example.lenovo.model.CategoryListModel;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.Bind;
import butterknife.ButterKnife;

import android.view.View;
import android.view.WindowManager;
import android.widget.TextView;

import com.example.lenovo.appstore.R;

import java.util.ArrayList;

public class PurchasedItemsActivity extends AppCompatActivity implements View.OnClickListener {
    @Bind(R.id.index_titleBar)
    TitleBarView index_titleBar;
    RankListAdapter adapter1, adapter2;
    @Bind(R.id.list1)
    RecyclerView list1;
    @Bind(R.id.list2)
    RecyclerView list2;
    @Bind(R.id.tab1)
    TextView tab1;
    @Bind(R.id.tab2)
    TextView tab2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_purchased_items);
        ButterKnife.bind(this);
        StatusBarUtil.immersive(this);
        StatusBarUtil.setStatusBarLightMode(getWindow());
        index_titleBar.setTitle(AppContext.getInstance().getResources().getString(R.string.Purchaseditems));
        getWindow().setSoftInputMode(
                WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
        tab1.setOnClickListener(this);
        tab2.setOnClickListener(this);
        ArrayList<CategoryListModel.CategoryList> datas1 = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            datas1.add(new CategoryListModel.CategoryList());
        }
        adapter1 = new RankListAdapter(PurchasedItemsActivity.this, datas1);
        ArrayList<CategoryListModel.CategoryList> datas2 = new ArrayList<>();
        for (int i = 0; i < 2; i++) {
            datas2.add(new CategoryListModel.CategoryList());
        }
        adapter2 = new RankListAdapter(PurchasedItemsActivity.this, datas2);
        list1.setLayoutManager(new LinearLayoutManager(PurchasedItemsActivity.this));
        list2.setLayoutManager(new LinearLayoutManager(PurchasedItemsActivity.this));
        list1.setAdapter(adapter1);
        adapter1.notifyDataSetChanged();
        list2.setAdapter(adapter2);
        adapter2.notifyDataSetChanged();
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.tab1:
                tab1.setBackgroundResource(R.drawable.textview_kxyjjx3);
                tab1.setTextColor(Color.parseColor("#FFFFFF"));
                tab2.setTextColor(Color.parseColor("#000000"));
                tab2.setBackgroundResource(R.drawable.textview_kxyjjx4);
                list2.setVisibility(View.GONE);
                list1.setVisibility(View.VISIBLE);
                break;
            case R.id.tab2:
                tab1.setBackgroundResource(R.drawable.textview_kxyjjx2);
                tab1.setTextColor(Color.parseColor("#000000"));
                tab2.setTextColor(Color.parseColor("#FFFFFF"));
                tab2.setBackgroundResource(R.drawable.textview_kxyjjx5);
                list1.setVisibility(View.GONE);
                list2.setVisibility(View.VISIBLE);
                break;
        }
    }
}
